package com.example.sofa_module.sofa.fragments.text;

import com.example.common.entity.BaseEntity;
import com.example.common.mvvm.databus.LiveDataBus;
import com.example.common.mvvm.viewmodel.BaseViewModel;
import com.example.sofa_module.sofa.entity.BeanEntity;
import com.example.sofa_module.sofa.entity.InvitationEntity;
import com.example.sofa_module.sofa.fragments.video.VideoModel;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class TextViewModel extends BaseViewModel<TextModel> {

    public LiveDataBus<List<BeanEntity>> sofa_list=new LiveDataBus<>();

    @Override
    public void onResult(BaseEntity entity) {
        if (entity instanceof InvitationEntity){
            InvitationEntity invitationEntity= (InvitationEntity) entity;
            List<BeanEntity> data = invitationEntity.data.getData();
            sofa_list.postValue(data);
        }
    }

    @Override
    protected void initData() {
        respository.requestInvitationList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }
}
